package com.wwwzh.himalayafm.adapter.recommend;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wwwzh.himalayafm.R;
import com.wwwzh.himalayafm.entity.recommend.albumdetailshow.AlbumDetailShowTracksList;

import java.util.List;

/**
 * Created by wen10 on 2016/12/8.
 */

public class AlbumShowAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        private Context context;
        private List<AlbumDetailShowTracksList> list;


    public AlbumShowAdapter(Context context, List<AlbumDetailShowTracksList> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        RecyclerView.ViewHolder viewHolder = null;
        switch (viewType){
            case R.layout.layout_album_show_child:
                View   rootView   = LayoutInflater.from(context).inflate(R.layout.layout_album_show_child,parent,false);

                viewHolder   = new ViewHolderShowTop(rootView);
                break;
            case R.layout.layout_album_show_child2:
                View rootView1   = LayoutInflater.from(context).inflate(R.layout.layout_album_show_child2,parent,false);

                viewHolder   = new ViewHolderShow(rootView1);
                break;
        }
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (position == 0){

        }else {

            ViewHolderShow viewHolderShow = (ViewHolderShow) holder;
            viewHolderShow.title.setText(list.get(position-1).getTitle());
        }

    }

    @Override
    public int getItemCount() {
        return list.size()+1;
    }


    @Override
    public int getItemViewType(int position) {

        return position==0?R.layout.layout_album_show_child:R.layout.layout_album_show_child2;
    }

    public  class  ViewHolderShowTop extends RecyclerView.ViewHolder{
        private LinearLayout showTopLL;

        public ViewHolderShowTop(View itemView) {
            super(itemView);
            showTopLL = (LinearLayout) itemView.findViewById(R.id.AlbumDeShowTop_LL);
        }
    }

    public  class  ViewHolderShow extends RecyclerView.ViewHolder{
        private RelativeLayout parentRecycler;
        private TextView title;
        public ViewHolderShow(View itemView) {
            super(itemView);
            parentRecycler = (RelativeLayout) itemView.findViewById(R.id.AlbumDeShow_RV);
            title = (TextView) itemView.findViewById(R.id.AlbumDeShowTitle_TV);
        }
    }

}
